package com.oauth.service.google.service;

import com.oauth.service.OAuthDAO;
import com.oauth.service.OAuthService;
import com.oauth.service.OAuthServiceException;
import com.oauth.service.google.beans.GoogleDocBean;

public class DocOAuthServiceImpl implements OAuthService<GoogleDocBean> {

	private OAuthDAO<GoogleDocBean> mGoogleDAO;

	@Override
	public void deleteToken(Long memberId) throws OAuthServiceException {
		getGoogleDAO().deleteToken(memberId);
	}

	@Override
	public GoogleDocBean getToken(Long memberId) throws OAuthServiceException {
		return getGoogleDAO().getToken(memberId);
	}

	@Override
	public GoogleDocBean persistToken(GoogleDocBean serviceBean) throws OAuthServiceException {
		if (serviceBean.getMemberId() == null
				|| serviceBean.getAccessToken() == null
				|| serviceBean.getAccessTokenSecret() == null) {
			throw new OAuthServiceException("Parameters are null" + serviceBean);
		}
		return getGoogleDAO().persistToken(serviceBean);
	}

	/**
	 * @return the googleDAO
	 */
	public OAuthDAO<GoogleDocBean> getGoogleDAO() {
		return mGoogleDAO;
	}

	/**
	 * @param pGoogleDAO the googleDAO to set
	 */
	public void setGoogleDAO(OAuthDAO<GoogleDocBean> pGoogleDAO) {
		mGoogleDAO = pGoogleDAO;
	}
	
	
}